class Solution {
public:
    int getnum(int n)
    {
        int ret=0;
        while(n)
        {
            int x=n%10;
            ret+=x*x;
            n/=10;
        }
        return ret;
    }
    bool isHappy(int n) {
        //快慢指针判断成环的是不是一个单个的1
        //此时的两个指针为数字
        int left=getnum(n);
        int right=getnum(left);
        while(left!=right)
        {
            left=getnum(left);
            right=getnum(getnum(right));
        }
        if(left==1)
        {
            return true;
        }
        else 
        {
            return false;
        }
    }
};